/*
 * Generated file. 
 * 
 * ByTag.java
 */
package xsp;

import com.ibm.xsp.page.compiled.AbstractCompiledPage;
import com.ibm.xsp.page.compiled.AbstractCompiledPageDispatcher;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.page.compiled.NoSuchComponentException;
import com.ibm.xsp.page.compiled.PageExpressionEvaluator;
import java.lang.String;
import javax.faces.el.MethodBinding;
import com.ibm.xsp.component.FacesPageProvider;
import com.ibm.xsp.resource.ScriptResource;
import com.ibm.xsp.resource.BundleResource;
import java.lang.Object;
import com.ibm.xsp.component.UIViewRootEx2;
import com.ibm.xsp.component.xp.XspEventHandler;
import com.ibm.xsp.component.UIIncludeComposite;
import com.ibm.xsp.binding.PropertyMap;
import com.ibm.xsp.component.UIPanelEx;
import java.lang.Boolean;

@SuppressWarnings("all")
public class ByTag extends AbstractCompiledPageDispatcher{
    
    public ByTag() {
        super("8.5.1"); // version of xp:eventHandler script
    }

    protected AbstractCompiledPage createPage(int pageIndex) {
        return new ByTagPage();
    }
    
    public static class ByTagPage extends AbstractCompiledPage {
        
        private static final ComponentInfo[] s_infos = new ComponentInfo[]{
            ComponentInfo.EMPTY_NORMAL, // 0 eventHandler
            ComponentInfo.EMPTY_NORMAL, // 1 "headerbar"
            ComponentInfo.EMPTY_NORMAL, // 2 "actionsbar"
            ComponentInfo.EMPTY_NORMAL, // 3 "maintopic"
            ComponentInfo.EMPTY_NORMAL, // 4 "bytagview"
            new ComponentInfo(false, new int[]{3, 4}), // 5 "refreshregion"
            new ComponentInfo(false, new int[]{1, 2, 5}), // 6 layout
            new ComponentInfo(false, new int[]{0, 6}), // 7 view
        };
        
        public ByTagPage() {
            super(7, s_infos );
        }
        
        public int getComponentForId(String id) throws NoSuchComponentException { 
            if( "headerbar".equals(id) )
                return 1;
            if( "actionsbar".equals(id) )
                return 2;
            if( "refreshregion".equals(id) )
                return 5;
            if( "maintopic".equals(id) )
                return 3;
            if( "bytagview".equals(id) )
                return 4;
            return -1;
        }
        
        public UIComponent createComponent(int id, FacesContext context,
                UIComponent parent, PageExpressionEvaluator evaluator)
                throws NoSuchComponentException { 
            switch (id) {
            case 7:
                return createView(context, parent, evaluator);
            case 0:
                return createEventHandler(context, parent, evaluator);
            case 6:
                return createLayout(context, parent, evaluator);
            case 1:
                return createHeaderbar(context, parent, evaluator);
            case 2:
                return createActionsbar(context, parent, evaluator);
            case 5:
                return createRefreshregion(context, parent, evaluator);
            case 3:
                return createMaintopic(context, parent, evaluator);
            case 4:
                return createBytagview(context, parent, evaluator);
            }
            throw new NoSuchComponentException(id);
        }
        
        protected void initIncluderAsRoot(FacesContext context,
                PageExpressionEvaluator evaluator, UIComponent root) {
            String sourceId = "/xp:view[1]/xp:this.afterPageLoad[1]/text()";
            MethodBinding afterPageLoad = evaluator.createMethodBinding(root,
                    "#{javascript:setDisplayFormType(null)}",
                    null,null, sourceId);
            FacesPageProvider asPageProvider = root instanceof FacesPageProvider ?
                    (FacesPageProvider) root : null;
            if( null != asPageProvider ){
                asPageProvider.setAfterPageLoad(afterPageLoad);
            }
            String sourceId2 = "/xp:view[1]/xp:this.beforePageLoad[1]/text()";
            MethodBinding beforePageLoad = evaluator.createMethodBinding(root,
                    "#{javascript:init()}",
                    null,null, sourceId2);
            if( null != asPageProvider ){
                asPageProvider.setBeforePageLoad(beforePageLoad);
            }
            ScriptResource resources = new ScriptResource();
            resources.setComponent(root);
            resources.setClientSide(false);
            resources.setSrc("/xpServerSide.jss");
            if( null != asPageProvider ){
                asPageProvider.addResource(resources);
            }
            ScriptResource resources2 = new ScriptResource();
            resources2.setComponent(root);
            resources2.setClientSide(false);
            resources2.setSrc("/mobile-server.jss");
            if( null != asPageProvider ){
                asPageProvider.addResource(resources2);
            }
            BundleResource resources3 = new BundleResource();
            resources3.setComponent(root);
            resources3.setSrc("/strings.properties");
            resources3.setVar("res");
            if( null != asPageProvider ){
                asPageProvider.addResource(resources3);
            }
            ScriptResource resources4 = new ScriptResource();
            resources4.setComponent(root);
            resources4.setClientSide(false);
            resources4.setSrc("/xpCGIVariables.jss");
            if( null != asPageProvider ){
                asPageProvider.addResource(resources4);
            }
            String sourceId3 = "/xp:view[1]/xp:this.beforeRenderResponse[1]/text()";
            MethodBinding beforeRenderResponse = evaluator.createMethodBinding(root,
                    "#{javascript:setPageHistory(res.getString(\"byTag.title\"), view.getPageName())}",
                    null,null, sourceId3);
            if( null != asPageProvider ){
                asPageProvider.setBeforeRenderResponse(beforeRenderResponse);
            }
            String pageTitleBnd = "#{javascript:@DbTitle()}";
            String sourceId4 = "/xp:view[1]/@pageTitle";
            Object pageTitle = evaluator.getBindingValue(root, pageTitleBnd, sourceId4, String.class);
            evaluator.setValue(root, "pageTitle", pageTitle, false, false);
        }

        private UIComponent createView(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIViewRootEx2 result = new UIViewRootEx2();
            initViewRoot(result);
            String sourceId = "/xp:view[1]/xp:this.afterPageLoad[1]/text()";
            MethodBinding afterPageLoad = evaluator.createMethodBinding(result,
                    "#{javascript:setDisplayFormType(null)}",
                    null,null, sourceId);
            result.setAfterPageLoad(afterPageLoad);
            String sourceId2 = "/xp:view[1]/xp:this.beforePageLoad[1]/text()";
            MethodBinding beforePageLoad = evaluator.createMethodBinding(result,
                    "#{javascript:init()}",
                    null,null, sourceId2);
            result.setBeforePageLoad(beforePageLoad);
            ScriptResource resources = new ScriptResource();
            resources.setComponent(result);
            resources.setClientSide(false);
            resources.setSrc("/xpServerSide.jss");
            result.addResource(resources);
            ScriptResource resources2 = new ScriptResource();
            resources2.setComponent(result);
            resources2.setClientSide(false);
            resources2.setSrc("/mobile-server.jss");
            result.addResource(resources2);
            BundleResource resources3 = new BundleResource();
            resources3.setComponent(result);
            resources3.setSrc("/strings.properties");
            resources3.setVar("res");
            result.addResource(resources3);
            ScriptResource resources4 = new ScriptResource();
            resources4.setComponent(result);
            resources4.setClientSide(false);
            resources4.setSrc("/xpCGIVariables.jss");
            result.addResource(resources4);
            String sourceId3 = "/xp:view[1]/xp:this.beforeRenderResponse[1]/text()";
            MethodBinding beforeRenderResponse = evaluator.createMethodBinding(result,
                    "#{javascript:setPageHistory(res.getString(\"byTag.title\"), view.getPageName())}",
                    null,null, sourceId3);
            result.setBeforeRenderResponse(beforeRenderResponse);
            String pageTitleBnd = "#{javascript:@DbTitle()}";
            String sourceId4 = "/xp:view[1]/@pageTitle";
            Object pageTitle = evaluator.getBindingValue(result, pageTitleBnd, sourceId4, String.class);
            evaluator.setValue(result, "pageTitle", pageTitle, false, false);
            return result;
        }

        private UIComponent createEventHandler(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspEventHandler result = new XspEventHandler();
            result.setSubmit(false);
            result.setEvent("onClientLoad");
            MethodBinding script = evaluator.createMethodBinding(result,
                    "if(!dojo.exists(\"ibm.xsp.widget.layout.xspClientRCP\")){insertLinks();}",
                    null,null, null);
            result.setScript(script);
            return result;
        }

        private UIComponent createLayout(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            String resultPage = "/layout.xsp";
            UIIncludeComposite result = new UIIncludeComposite();
            result.setPageDriver(getPageParam().getPageDriver());
            result.setPageName(resultPage);
            PropertyMap propertyMap = result.getPropertyMap();
            propertyMap.setProperty("navigationPath", "/byTag.xsp");
            return result;
        }

        private UIComponent createHeaderbar(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            String resultPage = "/headerBar.xsp";
            UIIncludeComposite result = new UIIncludeComposite();
            result.setPageDriver(getPageParam().getPageDriver());
            result.setPageName(resultPage);
            setId(result, "headerBar");
            PropertyMap propertyMap = result.getPropertyMap();
            String sourceId = "headerBar/@displayType";
            String displayTypeExpr = "#{javascript:DISPLAY_BY_TAG}";
            propertyMap.setProperty("displayType", evaluator.createValueBinding(result, displayTypeExpr, sourceId,int.class));
            return result;
        }

        private UIComponent createActionsbar(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            String resultPage = "/actionsBar.xsp";
            UIIncludeComposite result = new UIIncludeComposite();
            result.setPageDriver(getPageParam().getPageDriver());
            result.setPageName(resultPage);
            setId(result, "actionsBar");
            return result;
        }

        private UIComponent createRefreshregion(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIPanelEx result = new UIPanelEx();
            setId(result, "refreshRegion");
            return result;
        }

        private UIComponent createMaintopic(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            // loaded=??
            String loadedBnd = "#{javascript:getDisplayFormType() == 1}";
            String sourceId = "mainTopic/@loaded";
            String loaded = evaluator.evaluateAsString(null, loadedBnd, sourceId, boolean.class);
            if ( null != loaded && loaded.length() > 0 &&
                    ! Boolean.parseBoolean(loaded) ) {
                return null;
            } // else loaded was true
            String resultPage = "/mainTopic.xsp";
            UIIncludeComposite result = new UIIncludeComposite();
            result.setPageDriver(getPageParam().getPageDriver());
            result.setPageName(resultPage);
            PropertyMap propertyMap = result.getPropertyMap();
            propertyMap.setProperty("gotoPage", "/byTag.xsp");
            setId(result, "mainTopic");
            return result;
        }

        private UIComponent createBytagview(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            // loaded=??
            String loadedBnd = "#{javascript:getDisplayFormType() == null}";
            String sourceId = "byTagView/@loaded";
            String loaded = evaluator.evaluateAsString(null, loadedBnd, sourceId, boolean.class);
            if ( null != loaded && loaded.length() > 0 &&
                    ! Boolean.parseBoolean(loaded) ) {
                return null;
            } // else loaded was true
            String resultPage = "/byTagView.xsp";
            UIIncludeComposite result = new UIIncludeComposite();
            result.setPageDriver(getPageParam().getPageDriver());
            result.setPageName(resultPage);
            PropertyMap propertyMap = result.getPropertyMap();
            String sourceId2 = "byTagView/@rows";
            String rowsExpr = "#{javascript:(null == sessionScope.rows) ? DEFAULT_ROW_COUNT : sessionScope.rows}";
            propertyMap.setProperty("rows", evaluator.createValueBinding(result, rowsExpr, sourceId2,int.class));
            setId(result, "byTagView");
            return result;
        }

    }
}
